{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from xgboost import XGBClassifier\n",
    "import xgboost as xgb\n",
    "\n",
    "import time\n",
    "\n",
    "import numpy as np\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "import pandas as pd\n",
    "\n",
    "from sklearn.metrics import log_loss\n",
    "from sklearn.model_selection import GridSearchCV,StratifiedKFold"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "train = pd.read_csv(\"RentListingInquries_FE_train.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y_train = train['interest_level']\n",
    "x_train = train.drop(['interest_level'],axis=1)\n",
    "x_train = np.array(x_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#准备交叉验证参数\n",
    "kfold = StratifiedKFold(n_splits=5,shuffle=True,random_state=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#进一步确定弱学习器数目，这是一个三分类的问题 [2 1 0] 为高、中、低三类。直接调用XGBoost"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "xgb1 = XGBClassifier(\n",
    "    learning_rate=0.1,\n",
    "    n_estimators=150,    #第二次确定的学习器数目\n",
    "    max_depth=7,\n",
    "    min_child_weight=5,\n",
    "    gamma=0,\n",
    "    subsample=0.3,\n",
    "    colsample_bytree=0.8,\n",
    "    colsample_bylevel=0.7,\n",
    "    reg_alpha = 1.5,#调整的正则参数\n",
    "    reg_lambda = 0.5, #调整的正则参数\n",
    "    objective='multi:softprob',\n",
    "    seed=3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def modelfit(xlg,x_train,y_train,cv_folds=None,early_stopping_rounds=10):\n",
    "    xgb_param = xlg.get_xgb_params()\n",
    "    xgb_param['num_class'] = 3\n",
    "\n",
    "    xgtrain = xgb.DMatrix(x_train, label=y_train)\n",
    "\n",
    "    cvresult = xgb.cv(xgb_param, xgtrain, num_boost_round=xlg.get_params()['n_estimators'], folds=cv_folds,\n",
    "                      metrics='mlogloss', early_stopping_rounds=early_stopping_rounds)\n",
    "    cvresult.to_csv('n_estimators_1.csv', index_label='n_estimators')\n",
    "\n",
    "    n_estimators = cvresult.shape[0]\n",
    "\n",
    "\n",
    "    print(\"n_estimators is \",n_estimators)\n",
    "\n",
    "    xlg.set_params(n_estimators=n_estimators)\n",
    "    xlg.fit(x_train, y_train, eval_metric='mlogloss')\n",
    "\n",
    "    cvresult = pd.DataFrame.from_csv('n_estimators_1.csv')\n",
    "\n",
    "    test_means = cvresult['test-mlogloss-mean']\n",
    "    test_stds = cvresult['test-mlogloss-std']\n",
    "\n",
    "    train_means = cvresult['train-mlogloss-mean']\n",
    "    train_stds = cvresult['train-mlogloss-std']\n",
    "\n",
    "    x_axis = range(0, cvresult.shape[0])\n",
    "\n",
    "    plt.errorbar(x_axis, test_means, yerr=test_stds, label='Test')\n",
    "    plt.errorbar(x_axis, train_means, yerr=train_stds, label=\"Train\")\n",
    "\n",
    "    plt.title(\"XGBoost n_estimators vs Log Loss\")\n",
    "    plt.xlabel('n_estimators')\n",
    "    plt.ylabel('Log Loss')\n",
    "    plt.savefig('n_estimator_1.png')\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time.struct_time(tm_year=2018, tm_mon=5, tm_mday=29, tm_hour=10, tm_min=12, tm_sec=11, tm_wday=1, tm_yday=149, tm_isdst=0)\n",
      "n_estimators is  150\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEXCAYAAABCjVgAAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3Xl8XHW9//HXZyZrm7RpabrvpbSl\nWLZSdqggq0gFFUFQEZUrXkRQr4J6vV5+FzcURUEUEVBAFmWxIi5cNpEr0FJaCi0tbemSrilt2qZL\nkpl8fn98T5JpmrRp6eRMMu/n43E6c5Y55zNnmnnP2b7H3B0RERGARNwFiIhI7lAoiIhIM4WCiIg0\nUyiIiEgzhYKIiDRTKIiISDOFgkgGM/u6md0Rdx0icVEodDFmVmZmS83sYxnDys1suZl9OGPYZDN7\n3Mw2mlmNmc0zsxvMrE80/lIzS5tZbdQtMbMrslz7VDOryuYy9kZb9bj7d9z9M1la3lIze1825p0N\nnfV5dbX10t0pFLoYd68FLgduNrPKaPAPgJnu/gcAMzsOeBZ4ARjv7hXAmUAKODRjdv9y9zJ3LwM+\nDPzAzA7vnHcie8PMCuKuQfKEu6vrgh1wN3A/MBV4BxiUMe6fwM/28PpLgX+2GvYy8LGM/nOBN4Aa\nQshMyBg3IRpWE01zbsa4s4F5wBZgJfAVoCewHWgEaqNucDvv61bgz9HrXwLGdGB9jAeeBDYAC4AL\n9qUe4NvAvdHrRgIOfApYAWwEPgccBbwWvfdbMpYzBng6+jzWA/cBFdG4e6JlbY+W9dUOrOOlwNei\nZdUBBVH/yui9LABObWNdHAOsAZIZw84DXoueTwFmApuBtcBN7azTqUBVO+N6A78FqoFlwDeBRDQu\nCfwoWgdvA1dG67GgnXktBd7XzrjPAouiz3V60/8ZwIAfA+uATdE6OqS9zzvuv9eu1MVegLp9/OCg\nD7A6+sP7VMbwnkAamLqH119KRihEX3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NzGZGdf13NOwqQiN5z5jZM9Gwi8xsblTD9zNeX2tm15vZS8Cx\nZvY9M5sX3azlh9lZo5J34r6kWp26/dkBIwktZx4W9T8EXNLOtE8BY6PnRxPadoLQ/MCQ6HlF9Hgp\ncEvGa5v7CTdZeYDQhME0YDPwHsKPrlcyamlqMiIJPAtMivqX0tIMwmBCW0mVhBZgnwY+GI1z4IKm\neRGacrDMOtWpe7edthSkO3rb3WdHz18hBMVOoubKjwN+b2azgV8CTTc7eQG428w+S/gC74g/ubsT\nAmWth0bRGoE3MpZ/gZnNAl4l3B2srbv/HQU866FF1aZmoU+KxqUJLepCCJ4dwB1mdj6wbZc5ieyD\ngj1PItLl1GU8TwNt7T5KEG5yc1jrEe7+OTM7mnDHudlmtss0u1lmY6vlNwIFUaudXwGOcveN0W6l\nkjbm01Z7+012eHQcwd1TZjaF0OLqhcCVhKbNRd4VbSlIXvJwM6O3zewj0HxD9UOj52Pc/SV3/xaw\nntD+/Rag/F0sshfhBkCbzGwAO99kJ3PeLwEnm1m/6P7CFwHPtZ5ZtKXT292fAK4mtBQr8q5pS0Hy\n2cXAbWb2TaCQcFxgDnCjmY0l/Gp/Khq2HLg22tX03b1dkLvPMbNXCbuTlhB2UTW5HfiLma129/ea\n2XWEey0Y8IS7t3WfhXLgj2ZWEk13zd7WJNIWnZIqIiLNtPtIRESaafeRdHtmdivhftOZbnb3u+Ko\nRySXafeRiIg00+4jERFpplAQEZFmCgUREWmmUBARkWb/H22GKuu3Dv/rAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x25543d57668>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time.struct_time(tm_year=2018, tm_mon=5, tm_mday=29, tm_hour=10, tm_min=20, tm_sec=32, tm_wday=1, tm_yday=149, tm_isdst=0)\n"
     ]
    }
   ],
   "source": [
    "print(time.localtime(time.time()))\n",
    "modelfit(xgb1, x_train, y_train, cv_folds=kfold)\n",
    "print(time.localtime(time.time()))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "### 第三次确定学习器数目为150"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
